/**
 * Copyright &copy; 2021-2026 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.sys.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.jeeplus.core.domain.TreeMapper;
import com.jeeplus.sys.domain.Office;
import com.jeeplus.sys.service.dto.OfficeDTO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 机构MAPPER接口
 *
 * @author jeeplus
 * @version 2021-05-16
 */
public interface OfficeMapper extends TreeMapper <Office> {

    public List<Office> findAllOffices();

    /**
     * 机构列表
     *
     * @return
     */
    public List <OfficeDTO> findList(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);

    void deleteDeptUserAndTypeByDeptId(String id);

    void insertDeptUserAndType(List<Map<String, String>> userList);
    @MapKey("id")
    List<Map<String, String>> getDeptUserType(String id);

    // 查询子机构（type IN ('1','2','3','4')）
    @Select("SELECT * FROM sys_office WHERE parent_id = #{id} AND del_flag = 0 AND type IN ('1','2','3','4')")
    List<Office> selectChildrenByParentIds(String id);
}
